package com.didi.gulimall.coupon.controller;

import com.didi.gulimall.common.utils.R;
import com.didi.gulimall.common.vo.OrderItemVo;
import com.didi.gulimall.coupon.service.OrderDiscountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author 10626
 * @Create 2021/7/7 15:57
 */
@Api(tags = "订单优惠接口")
@RestController
@RequestMapping("coupon/order")
public class OrderDiscountController {
    @Autowired
    private OrderDiscountService orderDiscountService;

    @PostMapping("query/{levelId}")
    public R queryOrderDistant(
            @ApiParam(name = "levelId", value = "会员等级")
            @PathVariable("levelId") Long levelId,
            @ApiParam(name = "cartItems", value = "订单Vo")
            @RequestBody List<OrderItemVo> cartItems) {
        return orderDiscountService.queryOrderDistant(levelId, cartItems);
    }

    @PostMapping("check/levelId}")
    public R checkOrderDistant(
            @ApiParam(name = "levelId", value = "会员等级")
            @PathVariable("levelId") Long levelId,
            @ApiParam(name = "cartItems", value = "订单Vo")
            @RequestBody List<OrderItemVo> cartItems) {
        return orderDiscountService.checkOrderDistant(levelId, cartItems);
    }
}
